home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1997 September
/
Macworld (1997-09).dmg
/
Shareware World
/
Utilities
/
Text Processing
/
Alpha
/
Tcl
/
SystemCode
/
dial.tcl
< prev
next >
Wrap
Text File
|
1997-03-26
|
4KB
|
157 lines
# (nowrap)
set menuFlags(defaultFont) "system monaco courier geneva helvetica times {new york}"
set menuFlags(printerFont) "system monaco courier geneva helvetica times {new york}"
set menuFlags(printerFontSize) "9 10 12 14 18"
set menuFlags(fontSize) "9 10 12 14 18"
set menuFlags(savedState) "none think mpw"
proc suffixMappings {} {
global filepats
set l1 5
set w1 35
set l2 [expr $l1 + $w1 + 5]
set w2 200
set h 18
set top 5
set mar 5
set modes [lsort -ignore [array names filepats]]
set len [expr [llength $modes] + 1]
set modes1 [lrange $modes 0 [expr $len/2 - 1]]
set modes2 [lrange $modes [expr $len/2] end]
foreach m $modes1 {
lappend items -t $m $l1 $top [expr $l1 + $w1] [expr $top + $h]
lappend items -e $filepats($m) $l2 $top [expr $l2 + $w2] [expr $top + $h - 2]
incr top [expr $h + $mar]
}
set top2 5
set l1 [expr $l2 + $w2 + 20]
set l2 [expr $l1 + $w1 + 5]
foreach m $modes2 {
lappend items -t $m $l1 $top2 [expr $l1 + $w1] [expr $top2 + $h]
lappend items -e $filepats($m) $l2 $top2 [expr $l2 + $w2] [expr $top2 + $h - 2]
incr top2 [expr $h + $mar]
}
if {$top2 > $top} {
set top $top2
}
incr top $mar
set l1 5
lappend buts -b OK $l1 $top [expr $l1 + 60] [expr $top + 20]
lappend buts -b Cancel [expr $l1 + 100] $top [expr $l1 + 160] [expr $top + 20]
set res [eval "dialog -w [expr $l2 + $w2 + 10] -h [expr $top + 27]" $buts $items]
if {[car $res]} {
set res [cddr $res]
foreach m [lsort -ignore [array names filepats]] {
if {$filepats($m) != [car $res]} {
lappend changed [list $m [car $res]]
}
set res [cdr $res]
}
foreach pair $changed {
addArrDef filepats [car $pair] [cadr $pair]
set filepats([car $pair]) [cadr $pair]
}
}
updateSuffixes
}
bind f12 suffixDialog
proc modeDialog {flags vars {title ""}} {
global maxT
set left 20
set maxT 0
set args [dialSet $flags $vars 20 10 $title]
set height [expr $maxT + 30]
set buttons [concat -b OK $left [expr $height-30] [expr $left + 60] [expr $height-10] -b Cancel [expr $left + 100] [expr $height-30] [expr $left + 160] [expr $height-10]]
set res [eval [concat dialog -w 480 -h $height $buttons $args]]
if {[lindex $res 0]} {
return [lrange $res 2 end]
} else {
error "Cancel chosen"
}
}
proc dialSet {flags vars {left 20} {top 40} {title ""}} {
global maxT menuFlags
set t $top
if {$title != ""} {
lappend args "-t" $title 30 10 400 25
incr top 25
}
# if variable names are very long, switch to 2 columns
if {[maxListItemLength $flags] > 20} {
set perRow 2
set width 225
} else {
set perRow 3
set width 150
}
set height 15
set ind 0
foreach f $flags {
global $f
set l [expr $left + ($ind % $perRow) * $width]
set t [expr $top + ($ind / $perRow) * $height]
lappend args "-c" $f [set $f] $l $t [expr $l + $width] [expr $t + $height]
incr ind
}
if {$ind} {
set top [expr $t + 40]
lappend args -p 100 [expr $t + 27] 300 [expr $t + 28]
}
set perRow 1
set width 400
set height 17
set inc [expr $height + 10]
if {[maxListItemLength $vars] > 20} {
set lf 155
} else {
set lf 135
}
set ind 0
foreach v $vars {
global $v
set l [expr $left + ($ind % $perRow) * $width]
set t [expr $top + ($ind / $perRow) * $inc]
lappend args "-t" "$v:" $l $t [expr $l + $lf] [expr $t + $height]
if {[string match "*Color" $v]} {
lappend args "-m" [concat [list [set $v]] {none blue cyan green magenta red white yellow}] [expr $l + $lf -2] $t [expr $l + $width - 14] [expr $t + $height +1]
} elseif {[info exists menuFlags($v)]} {
lappend args "-m" [concat [list [set $v]] $menuFlags($v)] [expr $l + $lf -2] $t [expr $l + $width - 14] [expr $t + $height +1]
} else {
lappend args "-e" [set $v] [expr $l + $lf] $t [expr $l + $width - 10] [expr $t + $height +1]
}
incr ind
}
incr t 30
if {$t > $maxT} {set maxT $t}
return $args
}
proc maxListItemLength {l} {
regsub -all {\w} $l {A} l
return [string length [lindex [lsort -decreasing $l] 0]]
}